﻿@namespace BlazorFluentUI
@inherits FluentUIComponentBase

<LocalCS @bind-Rules="PersonaCoinLocalRules" />
<div @ref="RootElementReference" class=@($"{ClassName} mediumFont ms-Persona-coin") style=@Style>
    @if (Size != PersonaSize.Size8)
    {
        <div class=@($"ms-Persona-imageArea {LocalSpecificityClass} {ImageAreaRule.Selector?.SelectorName}")>
            @if (ShouldRenderInitials)
            {
                <div class=@($"ms-Persona-initials {LocalSpecificityClass} {InitialsRule.Selector?.SelectorName}{(ShowUnknownPersonaCoin? " ms-Personal-initials--showUnknownPersonaCoin" : "")}")
                     aria-hidden="true">
                    @if (ShowUnknownPersonaCoin)
                    {
                        <Icon IconName="help" />
                    }
                    else
                    {
                        var initials = GetInitials(Text, false, AllowPhoneInitials);
                        if (initials != "")
                        {
                            <span>@initials</span>
                        }
                        else
                        {
                            <Icon IconName="person" />
                        }
                    }
                </div>
            }
            @if (ImageUrl != null)
            {
                var dimension = CoinSize != -1 ? CoinSize : PersonaSize.SizeToPixels(Size);
                <Image Src=@ImageUrl
                          ClassName=@($"ms-Persona-image {LocalSpecificityClass} {ImageRule.Selector?.SelectorName}")
                          ImageFit=@ImageFit.Cover
                          Width=@dimension
                          Height=@dimension
                          Alt=@ImageAlt
                          ShouldFadeIn=@ImageShouldFadeIn
                          ShouldStartVisible=@ImageShouldStartVisible
                          OnLoadingStateChange=@OnPhotoLoadingStateChange />
            }
            @if (Presence != PersonaPresenceStatus.None)
            {
                <PersonaPresence CoinSize=@CoinSize IsOutOfOffice=@IsOutOfOffice Presence=@Presence PresenceTitle=@PresenceTitle Size=@Size />
            }
        </div>
    }
    else
    {
        if (Presence != PersonaPresenceStatus.None)
        {
            <PersonaPresence CoinSize=@CoinSize IsOutOfOffice=@IsOutOfOffice Presence=@Presence PresenceTitle=@PresenceTitle Size=@Size />
        }
        else
        {
            <Icon IconName="person" ClassName="ms-Persona-size10WithoutPresenceIcon" />
        }
    }
    @ChildContent
</div>
